package com.taxsystem.fangzicheng.taxpolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.main.taxsystem.ListAndSearchActivity;
import com.main.taxsystem.R;
import com.taxsystem.fangzicheng.taxpolicy.TaxPolicyActivity;

import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;


public class TaxPolicyActivity extends Activity {
	 private GridView gridView;
	 private static final String[] TITLES = new String[]{
		 "政策法规",
		 "税收优惠",
		 "政策解读",
		 "社保法规",
		 "社保申报流程",
		 "社保计算方法",
		 "价格调节资金法规",
		 "残疾人就业保障金法规",
		 "法规查询"
	 };
	 private static final int[] DRAWABLE_ID = new int[]{
		 R.drawable.zcfg,
		 R.drawable.ssyh,
		 R.drawable.zcjd,
		 R.drawable.sbfg,
		 R.drawable.sbsblc,
		 R.drawable.sbjsff,
		 R.drawable.jgtjfg,
		 R.drawable.cjrjybz,
		 R.drawable.fgcx
	 };
	 Intent intent;
	 int item = 0;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.grid_view_layout_cwz);
			gridView = (GridView) findViewById(R.id.gridView);
			
			ActionBar bar = getActionBar();
	        bar.setHomeButtonEnabled(true);
	        bar.setIcon(R.drawable.actionbar_icon);
	        bar.setDisplayHomeAsUpEnabled(true);
	        bar.setBackgroundDrawable(new ColorDrawable(0xff34a4f7));
	        
	       List<Map<String, Object>> data = new ArrayList<Map<String,Object>>();
	       for(int i=0;i<TITLES.length;i++){
	       Map<String,Object> map = new HashMap<String, Object>();
	          map.put("icon",DRAWABLE_ID[i]);
	          map.put("title", TITLES[i]);
	          data.add(map);
	       }
	      SimpleAdapter simpleAdapter = new SimpleAdapter(this, data,R.layout.grid_item, new String[]{"title","icon"}, new int[]{R.id.text_item,R.id.image_item});
	      gridView.setAdapter(simpleAdapter);
	      gridView.setOnItemClickListener(new OnItemClickListener() {
				@Override
				public void onItemClick(AdapterView<?> parent, View v,
						int position, long id) {
					Intent intent = new Intent(TaxPolicyActivity.this,ListAndSearchActivity.class);
					intent.putExtra("title", TITLES[position]);
					startActivity(intent);
				}
			});
		}
	}
